//网络请求封装


let baseURL ='https://api-hmugo-web.itheima.net/api/public'

function request(url,method,data){
  return new Promise(function(resolve,reject){
    wx.request({
      url: baseURL + url,
      method: method ||'GET',
      data: data || {},
      header: {
        'content-type': 'application/json' // 默认值
      },
      success (res) {
        if(res.data.meta.status === 200){
          console.log('获取完全成功',res.data);
          resolve(res.data)
        }else{
          console.log('请求未成功');
        }

        console.log(res.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}
export default request